package mya.mes.mdc.model.tag.convert;

import mya.mes.mdc.model.excel.ExcelTagAlarmDef;

import java.util.Map;

public class ExcelTagAlarmDefConverter {

  public static void fromJson(Map<String,Object> json, ExcelTagAlarmDef obj) {
    for (java.util.Map.Entry<String, Object> member : json.entrySet()) {
      switch (member.getKey()) {
        case "bit":
          if (member.getValue() instanceof Number) {
            obj.setBit(((Number)member.getValue()).intValue());
          }
          break;
        case "enUs":
          if (member.getValue() instanceof String) {
            obj.setEnUs((String)member.getValue());
          }
          break;
        case "index":
          if (member.getValue() instanceof Number) {
            obj.setIndex(((Number)member.getValue()).intValue());
          }
          break;
        case "msgNotice":
          if (member.getValue() instanceof Boolean) {
            obj.setMsgNotice((Boolean)member.getValue());
          }
          break;
        case "needSendToManager":
          if (member.getValue() instanceof Boolean) {
            obj.setNeedSendToManager((Boolean)member.getValue());
          }
          break;
        case "needSendToPerson":
          if (member.getValue() instanceof Boolean) {
            obj.setNeedSendToPerson((Boolean)member.getValue());
          }
          break;
        case "no":
          if (member.getValue() instanceof String) {
            obj.setNo((String)member.getValue());
          }
          break;
        case "plcAddress":
          if (member.getValue() instanceof String) {
            obj.setPlcAddress((String)member.getValue());
          }
          break;
        case "rdbTag":
          if (member.getValue() instanceof String) {
            obj.setRdbTag((String)member.getValue());
          }
          break;
        case "ref":
          if (member.getValue() instanceof String) {
            obj.setRef((String)member.getValue());
          }
          break;
        case "rowNum":
          if (member.getValue() instanceof Number) {
            obj.setRowNum(((Number)member.getValue()).intValue());
          }
          break;
        case "zhCN":
          if (member.getValue() instanceof String) {
            obj.setZhCN((String)member.getValue());
          }
          break;
      }
    }
  }

//  public static void toJson(ExcelTagAlarmDef obj, JsonObject json) {
//    toJson(obj, json.getMap());
//  }

  public static void toJson(ExcelTagAlarmDef obj, java.util.Map<String, Object> json) {
    if (obj.getBit() != null) {
      json.put("bit", obj.getBit());
    }
    if (obj.getEnUs() != null) {
      json.put("enUs", obj.getEnUs());
    }
    if (obj.getIndex() != null) {
      json.put("index", obj.getIndex());
    }
    if (obj.getMsgNotice() != null) {
      json.put("msgNotice", obj.getMsgNotice());
    }
    if (obj.getNo() != null) {
      json.put("no", obj.getNo());
    }
    if (obj.getPlcAddress() != null) {
      json.put("plcAddress", obj.getPlcAddress());
    }
    if (obj.getRdbTag() != null) {
      json.put("rdbTag", obj.getRdbTag());
    }
    if (obj.getRef() != null) {
      json.put("ref", obj.getRef());
    }
    json.put("rowNum", obj.getRowNum());
    if (obj.getZhCN() != null) {
      json.put("zhCN", obj.getZhCN());
    }
  }
}
